package com.cty.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cty.config.Result;
import com.cty.entity.User;
import com.cty.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("user")
public class UserController {
@Autowired
    UserService userService;
@RequestMapping("list")
    public Result list(@RequestBody User user){
    if (user!=null){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username",user.getUsername());
        User one = userService.getOne(wrapper);
        if (user.getPassword().equals(one.getPassword())){
                return Result.OK(one);

        }else {
            return Result.failed(202,"密码不正确");
        }
    }else {
        return Result.failed(202,"未有参数");
    }
}
}
